/**
 *
 * @authors Your Name (you@example.org)
 * @date    2016-12-31 15:01:26
 * @version $Id$
 */
$(function(){
/**
 *
 sale
 *
 */
(function(){

    function countDown(target,timeString){
        var future = 1;//未来1天。
        var now = new Date();
        var ms = now.getTime();
        // var end = ms + 24*60*60*1000*future;
        var end = Date.parse(timeString);
        var gap = end - ms;
        // console.log(ms);
        // console.log(end);
        // console.log(gap);
        var allS = parseInt(gap/1000);
        var allM = parseInt(allS/60);
        var allH = parseInt(allM/60);
        var allD = parseInt(allH/24);
        var d = allD%24;
        var h = allH%24;
        var m = allM%60;
        var s = allS%60;
        // function check(element){
        //     element = element < 10 ? ('0'+element) : element;
        //     // return element;
        // }
        if(s < 10 ){
            s = '0'+s;
        }
        if(m < 10 ){
            m = '0'+m;
        }
        if(h < 10 ){
            h = '0'+h;
        }
        $(target).text('还剩'+d+'天'+h+'时'+m+'分'+s+'秒');
        if(gap <= 0){
            $(target).text('抢购以结束、请明天再来吧。');
        }
    }//封装的倒计时
    countDown();
    setInterval(function(){
        countDown('.sale .left p','2017,01,10');
        countDown('.brand .content li:nth-child(1) .right p:nth-child(4)','2017,01,10,10:10:10');
        countDown('.brand .content li:nth-child(2) .right p:nth-child(4)','2017,01,10,12:12:14');
        countDown('.brand .content li:nth-child(3) .right p:nth-child(4)','2017,01,10,11:11:11');

    },500);



}());//sale end










/**
 *
 better
 *
 */
(function(){
    $('.better li').addClass('clearfix');

}());//better end

/**
 *
 brand
 *
 */
(function(){
    $('.brand .content li').addClass('clearfix');
    $('.brand .nav li').mouseenter(function(){
        $(this).addClass('active').siblings().removeClass('active');
    });



}());//brand end













}());//end